from fastapi import HTTPException
from sqlmodel import select
from api.deps import SessionDep
from models.order_initial_model import OrderInitial
async def find_order_initial_by_order_code(*,session:SessionDep,order_code:str):
    """通过订单号查询订单信息"""
    stmt = select(OrderInitial).where(OrderInitial.订单编码==order_code)
    result = await session.exec(stmt)
    db_order_initial = result.first()
    if db_order_initial is None:
        raise HTTPException(404,"订单不存在")
    else:
        await session.refresh(db_order_initial)
    return db_order_initial